package com.kfc.platform.transaction.domain;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import com.kfc.platform.user.domain.User;

import sun.security.util.BigInt;

@Entity
@Table(name = "kfc_userentrust")
@GenericGenerator(strategy = "native", name = "transaction")
public class TradeList {
	private static final String TYPE_STRATERGY = "^[买]|[卖]$";
	private static final String STATUS_STRATERGY = "^[未][成][交]|[已][成][交]|[部][分][成][交]|[部][分][撤][单]|[已][撤][单]$";
	private int listnum;
    private Integer version;//版本控制
	private BigDecimal price;//价格
	private BigDecimal amount;//数量
	private String username;//用户名
	private String trade_date;//交易时间
	private String type;//买卖类型
	private String status;//交易状态
	private BigDecimal sum;//挂单总金额
	@Column(nullable=false)
	@NotNull(message="挂单总额不能为空")
	public BigDecimal getSum() {
		return sum;
	}
	public void setSum(BigDecimal sum) {
		this.sum = sum;
	}
	@Column(nullable=false)
	@NotNull(message="数量不能为空！")
	public BigDecimal getAmount() {
		return amount;
	}
	@Id
	@GeneratedValue(generator="transaction")
	public int getListnum() {
		return listnum;
	}
	@Column(nullable=false)
	@NotNull(message="价钱不能为空！")
	public BigDecimal getPrice() {
		return price;
	}
	@Column(nullable=false)
	@Pattern(regexp=STATUS_STRATERGY,message="状态有误！")
	public String getStatus() {
		return status;
	}
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@NotNull(message="时间不能为空！")
	public String getTrade_date() {
		return trade_date;
	}
	@Column(nullable=false)
	@Pattern(regexp=TYPE_STRATERGY,message="交易类型只能为‘买’或‘卖’")
	public String getType() {
		return type;
	}
	@Column(nullable=false)
	@Size(min=6,max=32)
	@NotNull(message="用户名不能为空！")
	public String getUsername() {
		return username;
	}
	@Version
	public Integer getVersion() {
		return version;
	}
	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}
	public void setListnum(int listnum) {
		this.listnum = listnum;
	}
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public void setTrade_date(String trade_date) {
		this.trade_date = trade_date;
	}
	public void setType(String type) {
		this.type = type;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public void setVersion(Integer version) {
		this.version = version;
	}
	
}